<?php
/**
 *
 *
 * @author
 * @version
 */
class User_PrivateController extends Zen_Controller_Admin {


public function indexAction() {
		
		$form = new User_Form_Private ();
		
		$model = new User_Model_Users();
		$user_id = Zen_User::getId();
		$user = $model->select()->getOne("id=" . $user_id);
		$defaults = ($user['property']) ? unserialize($user['property']) : false;
			
		if ($defaults) {
			$form->setDefaults ( $defaults );
		}
		if ($this->_request->isPost ()) {
			if ($form->isValid ( $this->_getAllParams () )) {
				$property = serialize($form->getValues ());
				$model->update($user_id, array( 'property' => $property ));
				$this->_helper->FlashMessenger->setNamespace ( 'messages' )->addMessage ( array ('text' => 'Изменения сохранены', 'type' => 'alert' ) );
				$this->_redirect ( $_SERVER ['REQUEST_URI'] );
			}
		}
		$this->view->form = $form;
	}




}
